package com.iqi.onigao.module.quest;

import java.util.List;
import java.util.Map;

import com.iqi.onigao.constant.SessionConstant;
import com.iqi.onigao.context.Bean;
import com.iqi.onigao.module.friend.FriendBO;

import net.IClient;
import net.Package;
import si.client.CQuest;
import si.pod.FriendPOD;
import si.pod.ItemShowPOD;
import si.pod.PlayerPOD;
import si.pod.QuestPOD;
@Bean(QuestBO.class)
public class QuestBOImpl extends CQuest implements QuestBO{

	@Override
	public boolean commitQuestResult(IClient session, Package p, int code, int cid, List<ItemShowPOD> awards) {
		return false;
	}

	@Override
	public boolean giveUpQuestResult(IClient session, Package p, int code, int cid) {
		return false;
	}

	@Override
	public boolean notifyUpdateQuest(IClient session, Package p, QuestPOD updateQuest, boolean remove) {
		Map<Integer, QuestPOD> quests = session.getAttr(SessionConstant.QUESTS);
		if (remove) {
			quests.remove(updateQuest.getCid());
		}else {
			quests.put(updateQuest.getCid(), updateQuest);
		}
		return false;
	}

	@Override
	public boolean notifyFinishQuestList(IClient session, Package p, int cid, boolean remove) {
		Map<Integer, QuestPOD> quests = session.getAttr(SessionConstant.QUESTS);
		PlayerPOD player =  session.getAttr(SessionConstant.PLAYER);
		
		
		if (remove) {
			quests.remove(cid);
		}else {
			player.getFinishQuestList().add(cid);
		}
		return false;
	}

	@Override
	public boolean notifyFailQuestList(IClient session, Package p, int cid, boolean remove) {
		Map<Integer, QuestPOD> quests = session.getAttr(SessionConstant.QUESTS);
		PlayerPOD player =  session.getAttr(SessionConstant.PLAYER);
		if (remove) {
			quests.remove(cid);
		}else {
			player.getFailQuestList().add(cid);
		}
		
		return false;
	}

	@Override
	public boolean refreshBountyResult(IClient session, Package p, int code) {
		return false;
	}

}
